<!DOCTYPE html>

<html>

<head>
    <meta charset="utf-8">
    <title>异常报警</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../layuiadmin/style/admin.css" media="all">
    <link rel="stylesheet" href="//at.alicdn.com/t/font_739294_hnvvzy2r2u.css" media="all">
    <link rel="stylesheet" href="../../layuiadmin/layui/css/my.css" media="all">
</head>

<body>
    <div class="layui-form" style="margin-left:20px;margin-top:15px;margin-bottom:-20px">
        <div class="layui-form-item">
            <label class="layui-form-label">医院名称</label>
            <div class="layui-inline">
                <select class="layui-input" name="hospital" id="hospital" placeholder="请输入选择医院">
                        <option value=""></option> 
                </select>

            </div>
            <div class="layui-btn-group">
                <button class="layui-btn layui-btn-normal" data-type="reload" id="search"> <i class="layui-icon layui-icon-search"></i> 查询</button>
                <button class="layui-btn layui-btn-normal" data-type="reload" id="handle"> <i class="iconfont icon-iconfontwujingongju"></i> 处理结果</button>
                <button class="layui-btn layui-btn-normal" data-type="reload" id="f5"><i class="layui-icon">&#xe669;</i> 刷新</button>
            </div>
        </div>
    </div>
    <table id="demo" lay-filter="test"></table>
    <script src="../../layuiadmin/layui/layui.js"></script>
    <script>
        layui.config({
            base: '../../layuiadmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index']);
        layui.use('laydate', function() {
            var laydate = layui.laydate;

            //执行一个laydate实例
            laydate.render({
                elem: '#datetime', //指定元素
                theme: "#1e9fff"
            });
        });

        layui.use('table', function() {
            var table = layui.table;
            var $ = layui.$;
            var tableIns = table.render({
                elem: '#demo',
                height: 'full-90',
                data: [],
                page: true,
                cols: [
                    [ //表头

                        {
                            type: "radio"
                        }, {
                            field: 'sno',
                            title: '条码',
                            width: '12%',
                            event: "info"
                        }, {
                            field: 'pdate',
                            title: '异常日期',
                            width: '10%'

                        }, {
                            field: 'type',
                            title: '异常类型',
                            width: '10%',
                            templet: function(d) {
                                switch (parseInt(d.type)) {
                                    case 0:
                                        return '遗失';

                                        break;
                                    case 1:
                                        return '泄露';

                                        break;
                                    case 2:
                                        return '破损';

                                        break;
                                    default:
                                        return '';
                                        break;
                                }
                            }
                        }, {
                            field: 'cname',
                            title: '回收人',
                            width: '12%'
                        }, {
                            field: 'isover',
                            title: '是否已处理',
                            width: '11%',
                            templet: function(d) {
                                switch (parseInt(d.isover)) {
                                    case 0:
                                        return '未处理';
                                        break;
                                    case 1:
                                        return '已处理';
                                        break;
                                    default:
                                        return '';
                                        break;
                                }
                            }
                        }, {
                            field: 'result',
                            title: '处理结果',
                            width: '20%'
                        }, {
                            field: 'context',
                            title: '异常内容',
                            width: '20%'
                        }
                    ]
                ],
                skin: 'row' //表格风格
                    ,
                even: true
            });
            $.ajax({
                url: "../../../Cust/hospital",
                dataType: 'json',
                type: "get",
                success: function(res) {
                    $.each(res.data, function(index) {
                        var id = res.data[index].hid;
                        var name = res.data[index].name;
                        $("#hospital").append("<option value='" + id + "'>" + name + "</option>")
                    });
                    layui.form.render();
                }

            })
            table.on('rowDouble(test)', function(obj) {
                var d = obj.data;
                layer.open({
                    type: 2,
                    area: ['577px', '470px'],
                    offset: 'auto',
                    maxmin: true,
                    title: ['异常处理', 'background:#1E9FFF;color:white;font-size:17px;font-weight:bold'],
                    content: 'handleError.html',
                    success: function(layero, index) {
                        var body = layer.getChildFrame('body', index);
                        body.find("#context").val(d.context);
                        body.find("#id").val(d.id);
                        body.find("#sno").html(d.sno);
                        body.find("#result").val(d.result);
                    }
                });
            });
            table.on('tool(test)', function(obj) {
                var d = obj.data;
                if (obj.event === 'info') {
                    layer.open({
                        type: 2,
                        area: ['577px', '470px'],
                        offset: 'auto',
                        maxmin: true,
                        title: ['异常处理', 'background:#1E9FFF;color:white;font-size:17px;font-weight:bold'],
                        content: 'handleError.html',
                        success: function(layero, index) {
                            var body = layer.getChildFrame('body', index);
                            body.find("#context").val(d.context);
                            body.find("#id").val(d.id);
                            body.find("#sno").html(d.sno);
                            body.find("#result").val(d.result);
                        }
                    });
                }
            })
            $("#handle").on('click', function() {
                var checkStatus = table.checkStatus('demo');
                var d = checkStatus.data[0];

                layer.open({
                    type: 2,
                    area: ['577px', '470px'],
                    offset: 'auto',
                    maxmin: true,
                    title: ['异常处理结果', 'background:#1E9FFF;color:white;font-size:17px;font-weight:bold'],
                    content: 'handleError.html',
                    success: function(layero, index) {
                        var body = layer.getChildFrame('body', index);
                        body.find("#context").val(d.context);
                        body.find("#id").val(d.id);
                        body.find("#sno").html(d.sno);
                        body.find("#result").val(d.result);
                    }
                });
            })
            $("#f5").on("click", function() {
                tableIns.reload();

            })
            $("#search").on("click", function() {
                tableIns.reload({
                    url: "../../../Service/getException",
                    where: {
                        hid: $("#hospital option:selected").val()
                    }
                });

            })
        });
    </script>

</body>

</html>